package spring.jdbc.impl;

import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
import spring.jdbc.interfaces.IUserDao;
import spring.model.UserModel;

public class UserDaoImpl extends SimpleJdbcDaoSupport implements IUserDao {
    private static final String ISNERT_SQL = "insert into test(name) values (:myName)";
    private static final String COUNT_ALL_SQL = "select count(*) from test";

    @Override
    public void save(UserModel model) {
        getSimpleJdbcTemplate().update(ISNERT_SQL, new BeanPropertySqlParameterSource(model));


    }

    @Override
    public int countAll() {
        return getJdbcTemplate().queryForInt(COUNT_ALL_SQL);
    }

}
